{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# AI女友-沉浸式人格化情感交互体验\n",
    "## 简介\n",
    "借助大语言模型技术，挖掘单身男性的情感陪伴需求，实现了一个AI女友应用。\n",
    "\n",
    "功能与思路：利用精美的人物立绘和场景，实现自然语言自由对话；\n",
    "\n",
    "借助大语言模型提供的能力，实现包括情绪表现和语音合成在内的多模态交互，增强虚拟人物感染力；\n",
    "\n",
    "借助AI图像生成技术，实现自由的场景切换，探索内容场景无限的可能性。\n",
    "## 技术思路\n",
    "1. 应用技术架构：通过编写程序整合代理AIGC开放平台的提供的能力，结合精心设计的前端用户界面，结合实时通信技术，打造流畅的沉浸式应用体验。\n",
    "\n",
    "2. AI智能体构建：应用few-shot、COT等技巧，构造出高效的提示词，让大模型激发出优异的能力；充分利用大模型应用开发中的FunctionCalling技术，扩展了大模型的执行能力。\n",
    "\n",
    "3. 产品表现力：构造了记忆模块，辅助虚拟人物的记忆表现，针对性的召回与当前场景相关的回忆，提升用户体验；借助大模型驱动人物表情、动作，增强虚拟人物表现力；借助AI文生图技术，实现自由的场景切换，探索内容场景无限的可能性。\n",
    "\n",
    "\n",
    "## 作品特色\n",
    "\n",
    "- 利用prompt engineering精心构造的人设提示词\n",
    "- 利用few-shot等理论控制输出结构化，让大模型同时进行文本和感情两种信息输出\n",
    "- 借助function calling完成表情切换、AI文生图场景切换等功能，增强体验感\n",
    "- 记忆模块，针对性的主动将重要信息写入记忆，即使历史聊天记录清空，也可以从记忆模块读取重要信息\n",
    "\n",
    "\n",
    "## 技术栈\n",
    "前后端使用WebSocket技术通信，后端采用Python语言，Flask框架，调用百度ERNIE-BOT的API接口，前端采用Vue+ElementUI框架。架构较为合理，代码整洁，封装严谨，可维护性较强。\n",
    "\n",
    "## 效果图预览\n",
    "\n",
    "### 正常交谈\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/299b19510e41489589e1fe4222555533632e688b66244486ba57a2377cac535a)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/6c795b4e393b406e920a07bac8bf46d2394a28b1ff744d7dbc0ca100151a367c)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/2469d06bccfb4725919b8f6a6a2e5726ecdc1f3a11a34a898e592b39886bc118)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/a6a556d6706e42988d72905f6d0fae9150166e2c9102486e97c7ad61d41aca0e)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/b09dab7587ba46fd9e57261ae879f3de542217999e604093be8410d2b7aee0ef)\n",
    "### 记忆重要的事情\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/50a493bcc4b5459286e0f158118f837418f15cf5649d480584046db2ec243449)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/d084dad673e94dacbd1bff80cc2a24bd0d87412cc26344e4bb270123727d66d6)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/98f1538e479d46b88eca28fbdc90bd32570c94f5bcac4558ae13dbc11e732035)\n",
    "## 次日：重启AI机器人，清空历史会话。\n",
    "### 回忆重要的事情\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/6bdbba4f10f74324abe2f57a42ed97aa534fcdeb514a4ed49881ffb569eda33d)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/95058ba35e7d4789a56aafc36e871fa62486e69b5c7847d296fe278e85f7bc78)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/00463b973766497c8fa1862c1cad7e98c4a9e2c496c5441daa789cee0bf29be2)\n",
    "### 情绪改变（平静、开心、生气）\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/b9daa24850314b9f9a533d44a3ab0dc3480844c0955f43e7b170f536b08be087)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/4b3cc904751b436c821fe9ff3d377d40d61be0c6ce554f07a2ffb9cdd1239b50)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/6bd2a937b32a41a3bcf3d835e442fa39535450ae880642479b8c6f2590b15d3e)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/35e271b780de443f8713bda5ea75bf9fd4257c0df8d4449fb3e33c7965673fd0)\n",
    "\n",
    "\n",
    "### 切换场景（AI实时场景生成）\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/4624f2b3efd345fb90e827cb90cc113f90db98edf0014e21b01cac03eaf76cf5)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/ee1a3745298d4d9e82c62269387e9eb4c585c5e0e54a4c449a51dad18b46c799)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/454acd20adb14ec88424ee54ba70c926ecc7788f984b45828da9350d86afc732)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/641266f04cef4413968d361ccdd942222a74f1ab70744c49a62f939b21071b7f)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/a396cb0a76e743459f5fbecdca86a8049faf202905954079b9d7068ad45763e4)\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/00376bed8e594158a107d58a6173c0f594f8ef7eeadc478dac16085c02f6e38e)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 安装部署为服务\n",
    "\n",
    " - 点击BML CodeLab 右上角的 “部署”按钮\n",
    " - 选择第一个“独占机器”选项\n",
    " - 环境安装命令填写：**pip install flask flask_socketio rich zhipuai erniebot**\n",
    " - 服务启动命令听写：**python app.py**\n",
    " - 其他配置如下图\n",
    "\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/45c1abd9fe9f403f926d534d52aae18d1f7232e7d2f34191af22900a30748342)\n",
    "\n",
    "## 等待服务部署好后，就访问服务地址主页，就可以探索了！\n",
    "![](https://ai-studio-static-online.cdn.bcebos.com/496f2a96ff1840e9a716fd8f1fa51a54caaad2705ca5468b89ec5bd748bd15db)\n",
    "\n",
    "\n",
    " \n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Demo服务地址\n",
    "# https://9er3e0b3p8m2yet9.aistudio-hub.baidu.com/\n",
    "# A币用完后即失效，如果发现服务停止，可以自己搭建一下"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请点击[此处](https://ai.baidu.com/docs#/AIStudio_Project_Notebook/a38e5576)查看本环境基本用法.  <br>\n",
    "Please click [here ](https://ai.baidu.com/docs#/AIStudio_Project_Notebook/a38e5576) for more detailed instructions. "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "py35-paddle1.2.0"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
